package com.wd.health.model.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.wd.health.R;
import com.wd.health.model.bean.HistoryWzBean;

import java.text.SimpleDateFormat;
import java.util.List;

/**
 * @ProjectName:shopmall
 * @Package:com.wd.health.model.adapter
 * @ClassName:HistoryWzAdapter
 * @UpdateUser: 裴童童
 * @date: 2020/12/23
 */
public class HistoryWzAdapter extends RecyclerView.Adapter<HistoryWzAdapter.ViewHolder>{

    private List<HistoryWzBean.ResultBean> list;
    private Context context;
    private SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    public HistoryWzAdapter(List<HistoryWzBean.ResultBean> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder(View.inflate(context,R.layout.item_historywz,null));
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        holder.sdv_doctor_user.setImageURI(list.get(position).getImagePic());
        holder.tv_doctor_name.setText(list.get(position).getDoctorName());
        holder.tv_doctor_zhiwei.setText(list.get(position).getJobTitle());
        long inquiryTime = list.get(position).getInquiryTime();
        String format = simpleDateFormat.format(inquiryTime);
        holder.tv_doctor_time.setText(format);
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder {

        private final SimpleDraweeView sdv_doctor_user;
        private final TextView tv_doctor_name;
        private final TextView tv_doctor_zhiwei;
        private final TextView tv_doctor_time;
        private final Button btn_recording;
        private final Button btn_comment;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            sdv_doctor_user = itemView.findViewById(R.id.sdv_doctor_user);
            tv_doctor_name = itemView.findViewById(R.id.tv_doctor_name);
            tv_doctor_zhiwei = itemView.findViewById(R.id.tv_doctor_zhiwei);
            tv_doctor_time = itemView.findViewById(R.id.tv_doctor_time);
            btn_recording = itemView.findViewById(R.id.btn_recording);
            btn_comment = itemView.findViewById(R.id.btn_comment);
        }
    }
} 
